package design_pattern;

//模板方法
public class TemplateMethodPattern {
    public static void main(String[] args) {
        Cooking food = new CookingFood();
        food.cook();
    }
}

abstract class Cooking{
    protected abstract void step1();
    protected abstract void step2();
    public void cook(){
        System.out.println("做饭开始");
        step1();
        step2();
        System.out.println("做饭结束");
    }
}
class CookingFood extends Cooking{

    //重写步骤

    @Override
    protected void step1() {
        System.out.println("放鸡蛋和西红柿");
    }

    @Override
    protected void step2() {
        System.out.println("少放盐多放味精");
    }
}